<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button id="btn1">button1</button>
  <button id="btn2">button2</button>
  <button onclick="but3()">button3</button>

  <script type="text/javascript">
    const but1 = document.getElementById('btn1')
    but1.addEventListener('click', () => {
      alert('button1 had been clicked')
    })

    const but2 = document.getElementById('btn2')
    but2.onclick = () => {
      alert('button2 had been clicked')
    }

    const but3 = () => {
      alert('button3 had been clicked')
    }
  </script>
</body>

</html>